import { patient_bind_famliy } from "@/services/patient";
import { ProColumns, ProTable } from "@ant-design/pro-components"

interface Iprops {
    patientId: number | undefined;
}
type GithubIssueItem = {
    icon: string;
    id: string;
    name: string;
    training_date: string;
    video_time: string;
    number: string;
    status: number;
};
const BindFamilyMembers = (props: Iprops) => {
    const { patientId } = props;

    // 获取患者绑定家属列表
    const get_patient_bind_famliy = async (params: {
        pageSize?: number | undefined;
        current?: number | undefined;
        keyword?: string | undefined;
    }) => {
        //默认分页参数和后端接口字段不匹配
        let request_body = {
            ...params,
            patient_id: patientId,
            current: params.current,
            pageSize: params.pageSize,
        };
        let res = await patient_bind_famliy(request_body)
        console.log('患者绑定家属列表', res);
        return {
            data: res.data.list,
            success: true,
            total: res.data.total_count,
        };
    }

    // 列表字段
    const columns: ProColumns<GithubIssueItem>[] = [
        {
            title: '序号',
            align: 'center',
            dataIndex: 'index',
            valueType: 'index',
        },
        {
            title: '姓名',
            align: 'center',
            dataIndex: 'famliy_name',
            key: 'famliy_name',
        },
        {
            title: '手机号',
            dataIndex: 'famliy_phone',
            align: 'center',
            key: 'famliy_phone',
        },
        {
            title: '绑定时间',
            align: 'center',
            key: 'create_time',
            dataIndex: 'create_time',
        },
    ];
    return <div>
        <ProTable
            columns={columns}
            request={async (params = {}) => get_patient_bind_famliy(params)}
            rowKey={(record) => record.id}
            search={false}
            toolBarRender={false}
            size="middle"
            pagination={{
                pageSize: 10,
                showSizeChanger: false,
            }}
            dateFormatter="string"
        />
    </div>
}
export default BindFamilyMembers;